<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	class LoggerTest extends AbstractTekunaTestCase {

		private $sLogFilename;


		public function setUp() {

			parent :: setUp();

			$this -> sLogFilename = TEKUNA_ROOT .'/../log/test.log';
		}


		public function testCreate() {

			@unlink($this -> sLogFilename);

			$this -> assertFalse(file_exists($this -> sLogFilename));

			$objLogger = new SimpleLogger($this -> sLogFilename);
			$objLogger -> log('just a test');

			$this -> assertTrue(file_exists($this -> sLogFilename));
		}


		public function testStore() {

			@unlink($this -> sLogFilename);

			$objLogger = new SimpleLogger($this -> sLogFilename);
			$objLogger -> log('the message');
			$arrStored = $objLogger -> getLogData();

			$this -> assertTrue(isset($arrStored[0]));
			$this -> assertTrue(isset($arrStored[0]['date']));
			$this -> assertTrue(isset($arrStored[0]['message']));
			$this -> assertEqual($arrStored[0]['message'], 'the message');
		}


		public function tearDown() {

			parent :: tearDown();

			@unlink($this -> sLogFilename);
		}
	}


